import 'package:distribution_mall_flutter/generated/json/base/json_convert_content.dart';
import 'package:distribution_mall_flutter/pages/merchant_authentication/domain/merchant_auth_last_entity.dart';

MerchantAuthLastBody $MerchantAuthLastBodyFromJson(Map<String, dynamic> json) {
  final MerchantAuthLastBody merchantAuthLastBody = MerchantAuthLastBody();
  final String? certificateId = jsonConvert.convert<String>(
      json['certificateId']);
  if (certificateId != null) {
    merchantAuthLastBody.certificateId = certificateId;
  }
  final String? distributorId = jsonConvert.convert<String>(
      json['distributorId']);
  if (distributorId != null) {
    merchantAuthLastBody.distributorId = distributorId;
  }
  final int? applyTime = jsonConvert.convert<int>(json['applyTime']);
  if (applyTime != null) {
    merchantAuthLastBody.applyTime = applyTime;
  }
  final String? auditState = jsonConvert.convert<String>(json['auditState']);
  if (auditState != null) {
    merchantAuthLastBody.auditState = auditState;
  }
  final String? rejectReason = jsonConvert.convert<String>(
      json['rejectReason']);
  if (rejectReason != null) {
    merchantAuthLastBody.rejectReason = rejectReason;
  }
  final int? auditTime = jsonConvert.convert<int>(json['auditTime']);
  if (auditTime != null) {
    merchantAuthLastBody.auditTime = auditTime;
  }
  final String? certificateType = jsonConvert.convert<String>(
      json['certificateType']);
  if (certificateType != null) {
    merchantAuthLastBody.certificateType = certificateType;
  }
  final String? businessName = jsonConvert.convert<String>(
      json['businessName']);
  if (businessName != null) {
    merchantAuthLastBody.businessName = businessName;
  }
  final String? certificateNo = jsonConvert.convert<String>(
      json['certificateNo']);
  if (certificateNo != null) {
    merchantAuthLastBody.certificateNo = certificateNo;
  }
  final String? businessPermitUrl = jsonConvert.convert<String>(
      json['businessPermitUrl']);
  if (businessPermitUrl != null) {
    merchantAuthLastBody.businessPermitUrl = businessPermitUrl;
  }
  final MerchantAuthAddress? address = jsonConvert.convert<MerchantAuthAddress>(
      json['address']);
  if (address != null) {
    merchantAuthLastBody.address = address;
  }
  final MerchantAuthLastBodyPhoneNumber? phoneNumber = jsonConvert.convert<
      MerchantAuthLastBodyPhoneNumber>(json['phoneNumber']);
  if (phoneNumber != null) {
    merchantAuthLastBody.phoneNumber = phoneNumber;
  }
  return merchantAuthLastBody;
}

Map<String, dynamic> $MerchantAuthLastBodyToJson(MerchantAuthLastBody entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['certificateId'] = entity.certificateId;
  data['distributorId'] = entity.distributorId;
  data['applyTime'] = entity.applyTime;
  data['auditState'] = entity.auditState;
  data['rejectReason'] = entity.rejectReason;
  data['auditTime'] = entity.auditTime;
  data['certificateType'] = entity.certificateType;
  data['businessName'] = entity.businessName;
  data['certificateNo'] = entity.certificateNo;
  data['businessPermitUrl'] = entity.businessPermitUrl;
  data['address'] = entity.address?.toJson();
  data['phoneNumber'] = entity.phoneNumber?.toJson();
  return data;
}

extension MerchantAuthLastBodyExtension on MerchantAuthLastBody {
  MerchantAuthLastBody copyWith({
    String? certificateId,
    String? distributorId,
    int? applyTime,
    String? auditState,
    String? rejectReason,
    int? auditTime,
    String? certificateType,
    String? businessName,
    String? certificateNo,
    String? businessPermitUrl,
    MerchantAuthAddress? address,
    MerchantAuthLastBodyPhoneNumber? phoneNumber,
  }) {
    return MerchantAuthLastBody()
      ..certificateId = certificateId ?? this.certificateId
      ..distributorId = distributorId ?? this.distributorId
      ..applyTime = applyTime ?? this.applyTime
      ..auditState = auditState ?? this.auditState
      ..rejectReason = rejectReason ?? this.rejectReason
      ..auditTime = auditTime ?? this.auditTime
      ..certificateType = certificateType ?? this.certificateType
      ..businessName = businessName ?? this.businessName
      ..certificateNo = certificateNo ?? this.certificateNo
      ..businessPermitUrl = businessPermitUrl ?? this.businessPermitUrl
      ..address = address ?? this.address
      ..phoneNumber = phoneNumber ?? this.phoneNumber;
  }
}

MerchantAuthLastBodyPhoneNumber $MerchantAuthLastBodyPhoneNumberFromJson(
    Map<String, dynamic> json) {
  final MerchantAuthLastBodyPhoneNumber merchantAuthLastBodyPhoneNumber = MerchantAuthLastBodyPhoneNumber();
  final int? countryCode = jsonConvert.convert<int>(json['countryCode']);
  if (countryCode != null) {
    merchantAuthLastBodyPhoneNumber.countryCode = countryCode;
  }
  final int? callingNumber = jsonConvert.convert<int>(json['callingNumber']);
  if (callingNumber != null) {
    merchantAuthLastBodyPhoneNumber.callingNumber = callingNumber;
  }
  return merchantAuthLastBodyPhoneNumber;
}

Map<String, dynamic> $MerchantAuthLastBodyPhoneNumberToJson(
    MerchantAuthLastBodyPhoneNumber entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['countryCode'] = entity.countryCode;
  data['callingNumber'] = entity.callingNumber;
  return data;
}

extension MerchantAuthLastBodyPhoneNumberExtension on MerchantAuthLastBodyPhoneNumber {
  MerchantAuthLastBodyPhoneNumber copyWith({
    int? countryCode,
    int? callingNumber,
  }) {
    return MerchantAuthLastBodyPhoneNumber()
      ..countryCode = countryCode ?? this.countryCode
      ..callingNumber = callingNumber ?? this.callingNumber;
  }
}

MerchantAuthAddress $MerchantAuthAddressFromJson(Map<String, dynamic> json) {
  final MerchantAuthAddress merchantAuthAddress = MerchantAuthAddress();
  final String? city = jsonConvert.convert<String>(json['city']);
  if (city != null) {
    merchantAuthAddress.city = city;
  }
  final String? country = jsonConvert.convert<String>(json['country']);
  if (country != null) {
    merchantAuthAddress.country = country;
  }
  final String? detailed = jsonConvert.convert<String>(json['detailed']);
  if (detailed != null) {
    merchantAuthAddress.detailed = detailed;
  }
  final String? district = jsonConvert.convert<String>(json['district']);
  if (district != null) {
    merchantAuthAddress.district = district;
  }
  final String? province = jsonConvert.convert<String>(json['province']);
  if (province != null) {
    merchantAuthAddress.province = province;
  }
  final String? street = jsonConvert.convert<String>(json['street']);
  if (street != null) {
    merchantAuthAddress.street = street;
  }
  return merchantAuthAddress;
}

Map<String, dynamic> $MerchantAuthAddressToJson(MerchantAuthAddress entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['city'] = entity.city;
  data['country'] = entity.country;
  data['detailed'] = entity.detailed;
  data['district'] = entity.district;
  data['province'] = entity.province;
  data['street'] = entity.street;
  return data;
}

extension MerchantAuthAddressExtension on MerchantAuthAddress {
  MerchantAuthAddress copyWith({
    String? city,
    String? country,
    String? detailed,
    String? district,
    String? province,
    String? street,
  }) {
    return MerchantAuthAddress()
      ..city = city ?? this.city
      ..country = country ?? this.country
      ..detailed = detailed ?? this.detailed
      ..district = district ?? this.district
      ..province = province ?? this.province
      ..street = street ?? this.street;
  }
}